
import { useEffect } from "react";
import { getAllBooksAsync } from "./redux/modules/booksSlice.ts";
import { useAppDispatch } from "./redux/index.ts";
import { useRoutes } from "react-router";
import {routes} from "./router/index.tsx"



const App:React.FC=()=>{

  // redux修改数据
const disPatch = useAppDispatch()


// 组件一挂载就执行
useEffect(()=>{
  disPatch(getAllBooksAsync())
},[disPatch])



  return (
    <div className="App">
      {/* 主视区 */}
      {useRoutes(routes)} 
    </div>
  )
}

export default App;
